<?php
if($_REQUEST['_m'] == "del") {
	
	$sql = "delete from resource_centre where id='".$_REQUEST['book_id']."'";
	mysql_query($sql) or die(mysql_error());
}
?>
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%">
<tr>
<td>Resource Centre</td>
<td align="right"><a href="index.php?tc=add_resource" class="font12">Add New</a></td>
</tr>
<tr>
<td colspan="100%">
<form name="formBook" onsubmit="return validateBook()">
<table cellspacing="0" cellpadding="0" border="1" align="center" width="100%"  class="list">
  <tbody>
  <tr style="background-color:#CCC">
   <td width="9%">#</td>
   <td width="25%">Concept</td>
   <td width="42%">URL</td>
   <td width="13%">Status</td>
   <td width="11%">Action</td>
  </tr>
  <?php
  
include('includes/function.php');
$self="index.php?tc=resource&_st=".$_REQUEST['_st'];
$rowsPerPage = 10;
$pageNum = 1;
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}
if($_GET['page']=="")
{
	$pageNum = 1;
}


$offset = ($pageNum - 1) * $rowsPerPage;
$st = $_REQUEST['_st'];

$res = mysql_query("select id from resource_centre");
$query = mysql_query("select * from resource_centre order by id desc limit $offset , $rowsPerPage") or die(mysql_error());
$i = 1;
  while($data = mysql_fetch_array($query)) {
	
	  ?>
	  <tr class="font12">
      <td align="center"><?php echo $i+$offset;?></td>
      <td>&nbsp;<?php echo $data['concept'];?></td>
      <td>&nbsp;<?php echo $data['url'];?></td>
      <td>&nbsp;<?php  
	  if($data['status'] == "1")
	  {
		  echo "Activated";
	  }
	  else {
		   echo "Deactivated";
	  }
	  ?></td>
      <td><a href="index.php?tc=resource&book_id=<?php echo $data['id'];?>&_m=del" class="font12" onClick="return confirm('Are you sure want to delete?');">Delete</a></td>
      </tr>
  <?php    
    $i++;}
  ?>
</tbody></table>
</form>
</td>
</tr>
<?php 
if(mysql_num_rows($res) <= $rowsPerPage){	}
else { ?>
<tr>
    <td colspan="13" align="center"  bgcolor="#FFFFFF">
        <?php echo $paginglink=getPagingLink($res, $rowsPerPage,$pageNum,$self); ?>	
    </td>
</tr>
<?php } ?>
</table>